<template>
  <div :ref="refName" :style="{ height: height, width: width }" />
</template>

<script>
import resize from "@/mixins/chartResize";
export default {
  name: "VsChart",
  mixins: [resize],
  props: {
    // 样式
    width: {
      type: String,
      default: "100%",
    },
    height: {
      type: String,
      default: "100%",
    },
    refName: {
      type: String,
      default: "chart",
    },
    options:{
      type:Object
    }
  },
  data() {
    return {
      chart: null,
    };
  },
  watch: {
    options: {
      handler(newVal) {
        newVal && this.drawChart();
      },
      deep: true,
    },
  },
  mounted() {
    this.$nextTick(()=>{
      this.drawChart();
    })
  },
  methods: {
   drawChart() {
      this.chart = this.$echarts.init(this.$refs[this.refName], "macarons");
      this.chart.setOption(this.options);
    },
  },
};
</script>

<style lang="less" scoped>
</style>
